package dq.study.designmodel.observer;

import java.text.SimpleDateFormat;

/**
 * @author dongqun
 * @Description:
 * @date 2019/4/15 22:21
 */
public class Client {


    public static void main(String[] args){
        Child child = new Child();
        child.addListener(event -> {
            // 打印事件内容
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            System.out.println("儿子："+event.getAction()+",我在"+event.getLocation()+"--"+format.format(event.getDate()));
        });
        // 爸爸对事件的处理
        child.addListener(new Dad());
        // 爷爷对事件的处理
        child.addListener(new GrandParent());
        new Thread(child).start();
    }
}
